<?php
//
//$Id: install-mysql.php 129 2011-06-08 18:25:15Z stormerider $
//

//--------------------------------------------------------

// 
// Table structure for table `{$db_prefix}alarms`
// 

$sql[]	= "DROP TABLE IF EXISTS `{$db_prefix}alarms`;";
$sql[]	= "CREATE TABLE `{$db_prefix}alarms` (
  `alarm_id` int(11) NOT NULL auto_increment,
  `alarm_user_id` int(11) NOT NULL default '0',
  `alarm_room_to` int(11) NOT NULL default '0',
  `alarm_user_to` int(11) NOT NULL default '0',
  `alarm_time` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
  `alarm_text` text NOT NULL,
  `alarm_type` tinyint(4) NOT NULL default '0',
  `alarm_inactive` tinyint(4) NOT NULL default '0',
  PRIMARY KEY  (`alarm_id`),
  KEY `alarm_inactive` (`alarm_inactive`)
) TYPE=MyISAM;";

// --------------------------------------------------------

// 
// Table structure for table `{$db_prefix}aliases`
// 

$sql[]	= "DROP TABLE IF EXISTS `{$db_prefix}aliases`;";
$sql[]	= "CREATE TABLE `{$db_prefix}aliases` (
  `alias_id` int(11) NOT NULL auto_increment,
  `user_id` int(11) NOT NULL default '0',
  `user_alias` text NOT NULL,
  `user_avatar` varchar(200) NOT NULL default '',
  PRIMARY KEY  (`alias_id`)
) TYPE=MyISAM;";

// --------------------------------------------------------

// 
// Table structure for table `{$db_prefix}bans`
// 

$sql[]	= "DROP TABLE IF EXISTS `{$db_prefix}bans`;";
$sql[]	= "CREATE TABLE `{$db_prefix}bans` (
  `ban_id` int(11) NOT NULL auto_increment,
  `ban_type` enum('userid','ip') NOT NULL default 'userid',
  `ban_value` varchar(255) NOT NULL default '',
  `ban_date` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
  `ban_message` text NOT NULL,
  `ban_banner` int(11) NOT NULL default '0',
  PRIMARY KEY  (`ban_id`),
  KEY `ban_type` (`ban_type`)
) TYPE=MyISAM;";

// --------------------------------------------------------

// 
// Table structure for table `{$db_prefix}config`
// 

$sql[]	= "DROP TABLE IF EXISTS `{$db_prefix}config`;";
$sql[]	= "CREATE TABLE `{$db_prefix}config` (
  `config_name` varchar(255) NOT NULL default '',
  `config_value` varchar(255) NOT NULL default '',
  PRIMARY KEY  (`config_name`)
) TYPE=MyISAM;";

// --------------------------------------------------------

// 
// Table structure for table `{$db_prefix}events`
// 

$sql[]	= "DROP TABLE IF EXISTS `{$db_prefix}events`;";
$sql[]	= "CREATE TABLE `{$db_prefix}events` (
  `event_id` bigint(20) NOT NULL auto_increment,
  `user_id_from` mediumint(8) NOT NULL default '0',
  `room_id_to` int(11) NOT NULL default '0',
  `user_id_to` mediumint(8) NOT NULL default '0',
  `event_text` text NOT NULL,
  `event_date` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
  `event_chat_flags` int(11) NOT NULL default '0',
  `event_server_flags` int(11) NOT NULL default '0',
  PRIMARY KEY  (`event_id`),
  KEY `room_id_to` (`room_id_to`,`user_id_to`)
) TYPE=MyISAM;";

// --------------------------------------------------------

// 
// Table structure for table `{$db_prefix}ignore`
// 

$sql[]	= "DROP TABLE IF EXISTS `{$db_prefix}ignore`;";
$sql[]	= "CREATE TABLE `{$db_prefix}ignore` (
  `ignore_id` int(11) NOT NULL auto_increment,
  `ignoring_user_id` int(11) NOT NULL default '0',
  `ignored_user_id` int(11) NOT NULL default '0',
  `ignored_user_name` varchar(255) NOT NULL default '',
  PRIMARY KEY  (`ignore_id`),
  KEY `ignoring_user_id` (`ignoring_user_id`)
) TYPE=MyISAM;";

// --------------------------------------------------------

// 
// Table structure for table `{$db_prefix}logs`
// 

$sql[]	= "DROP TABLE IF EXISTS `{$db_prefix}logs`;";
$sql[]	= "CREATE TABLE `{$db_prefix}logs` (
  `log_id` int(11) NOT NULL auto_increment,
  `log_userid` int(11) NOT NULL default '0',
  `log_date` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
  `log_msg` text NOT NULL,
  PRIMARY KEY  (`log_id`),
  KEY `log_userid` (`log_userid`)
) TYPE=MyISAM;";

// 
// Dumping data for table `{$db_prefix}room_groups`
// 

$sql[]	= "INSERT INTO `{$db_prefix}events` VALUES (1, 0, 0, 0, '<b>StormChat starting up for the first time... welcome!</b>', NOW(), 0, 0);";

// --------------------------------------------------------

// 
// Table structure for table `{$db_prefix}ignore`
// 

$sql[]	= "DROP TABLE IF EXISTS `{$db_prefix}ignore`;";
$sql[]	= "CREATE TABLE `{$db_prefix}ignore` (
  `ignore_id` int(11) NOT NULL auto_increment,
  `ignoring_user_id` int(11) NOT NULL default '0',
  `ignored_user_id` int(11) NOT NULL default '0',
  `ignored_user_name` varchar(255) NOT NULL default '',
  PRIMARY KEY  (`ignore_id`),
  KEY `ignoring_user_id` (`ignoring_user_id`)
) TYPE=MyISAM;";

// --------------------------------------------------------

// 
// Table structure for table `{$db_prefix}logs`
// 

$sql[]	= "DROP TABLE IF EXISTS `{$db_prefix}logs`;";
$sql[]	= "CREATE TABLE `{$db_prefix}logs` (
  `log_id` int(11) NOT NULL auto_increment,
  `log_userid` int(11) NOT NULL default '0',
  `log_date` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
  `log_msg` text NOT NULL,
  PRIMARY KEY  (`log_id`),
  KEY `log_userid` (`log_userid`)
) TYPE=MyISAM;";

// --------------------------------------------------------

// 
// Table structure for table `{$db_prefix}prefs`
// 

$sql[]	= "DROP TABLE IF EXISTS `{$db_prefix}prefs`;";
$sql[]	= "CREATE TABLE `{$db_prefix}prefs` (
  `user_id` int(11) NOT NULL default '0',
  `user_tagline` varchar(255) NOT NULL default '',
  `user_login_msg` varchar(200) NOT NULL default '',
  `user_logout_msg` varchar(200) NOT NULL default '',
  `user_color` varchar(10) NOT NULL default '',
  `user_css` text NOT NULL,
  `user_snippet_pad` text NOT NULL,
  `user_alias` text NOT NULL,
  `user_show_avatars` tinyint(4) NOT NULL default '0',
  `user_show_smilies` tinyint(4) NOT NULL default '0',
  `user_allow_pms` tinyint(4) NOT NULL default '0',
  `user_allow_ext_pms` tinyint(4) NOT NULL default '0',
  `user_away` tinyint(1) NOT NULL default '0',
  `user_away_msg` varchar(200) NOT NULL default '',
  `user_word_start` int(11) NOT NULL default '0',
  `user_word_goal` int(11) NOT NULL default '0',
  `user_word_current` int(11) NOT NULL default '0',
  `user_lastvisit_chat` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
  PRIMARY KEY  (`user_id`)
) TYPE=MyISAM;";

// --------------------------------------------------------

// 
// Table structure for table `{$db_prefix}room_groups`
// 

$sql[]	= "DROP TABLE IF EXISTS `{$db_prefix}room_groups`;";
$sql[]	= "CREATE TABLE `{$db_prefix}room_groups` (
  `group_id` int(11) NOT NULL auto_increment,
  `group_name` varchar(255) NOT NULL default '',
  `group_dynamic` enum('yes','no') NOT NULL default 'no',
  PRIMARY KEY  (`group_id`)
) TYPE=MyISAM;";

// 
// Dumping data for table `{$db_prefix}room_groups`
// 

$sql[]	= "INSERT INTO `{$db_prefix}room_groups` VALUES (1, 'Public Rooms', 'no');";
$sql[]	= "INSERT INTO `{$db_prefix}room_groups` VALUES (2, 'Limited Rooms', 'no');";
$sql[]	= "INSERT INTO `{$db_prefix}room_groups` VALUES (3, 'Dynamic Rooms', 'yes');";
$sql[]	= "INSERT INTO `{$db_prefix}room_groups` VALUES (4, 'Private Rooms', 'no');";

// --------------------------------------------------------

// 
// Table structure for table `{$db_prefix}rooms`
// 

$sql[]	= "DROP TABLE IF EXISTS `{$db_prefix}rooms`;";
$sql[]	= "CREATE TABLE `{$db_prefix}rooms` (
  `room_id` int(11) NOT NULL auto_increment,
  `room_name` varchar(20) NOT NULL default '',
  `room_password` varchar(20) NOT NULL default '',
  `room_limit` int(11) NOT NULL default '0',
  `mod_group` varchar(20) NOT NULL default '2',
  `room_topic` text NOT NULL,
  `room_group` tinyint(4) NOT NULL default '0',
  `room_dynamic` enum('yes','no') NOT NULL default 'no',
  `room_creator` int(11) NOT NULL default '0',
  PRIMARY KEY  (`room_id`),
  KEY `room_group` (`room_group`)
) TYPE=MyISAM;";

// 
// Dumping data for table `{$db_prefix}rooms`
// 

$sql[]	= "INSERT INTO `{$db_prefix}rooms` VALUES (1, 'General Room', '', 0, 2, 'Welcome to StormChat', 1, 'no');";

// --------------------------------------------------------

// 
// Table structure for table `{$db_prefix}sessions`
// 

$sql[]	= "DROP TABLE IF EXISTS `{$db_prefix}sessions`;";
$sql[]	= "CREATE TABLE `{$db_prefix}sessions` (
  `session_id` varchar(32) NOT NULL default '',
  `user_id` mediumint(8) NOT NULL default '0',
  `username` varchar(255) NOT NULL default '',
  `room_id` int(11) NOT NULL default '0',
  `idle_timer` int(11) default '0',
  `pull_timer` int(11) NOT NULL default '0',
  `server_push` tinyint(1) NOT NULL default '0',
  `moderator` tinyint(1) NOT NULL default '0',
  `avatar_url` varchar(255) NOT NULL default '',
  `board_avatar_url` varchar(255) NOT NULL default '',
  `user_browser` varchar(255) NOT NULL default '',
  `user_ip` varchar(15) NOT NULL default '',
  PRIMARY KEY  (`session_id`)
) TYPE=MyISAM;";

// --------------------------------------------------------

// 
// Table structure for table `{$db_prefix}smilies`
// 

$sql[]	= "DROP TABLE IF EXISTS `{$db_prefix}smilies`;";
$sql[]	= "CREATE TABLE `{$db_prefix}smilies` (
  `smilies_id` smallint(5) unsigned NOT NULL auto_increment,
  `code` varchar(50) default NULL,
  `smile_url` varchar(100) default NULL,
  `emoticon` varchar(75) default NULL,
  PRIMARY KEY  (`smilies_id`)
) TYPE=MyISAM;";

?>
